import com.java.onlineshop.pojo.Product;
import com.java.onlineshop.util.JdbcUtil;
import org.junit.jupiter.api.Test;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 * @program: onlineshop
 * @description:
 * @author: ShuangChenYue
 * @create: 2021-06-10 20:48
 **/
public class test
{
    @Test
    public void test()
    {
        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;
        try
        {
            connection = JdbcUtil.getConnection();
            connection.setAutoCommit(false);
            String sql = "select * from product where id=1";
            preparedStatement = connection.prepareStatement(sql);
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next())
            {
                Product product = new Product();
                product.setCartimages(resultSet.getString("cartimages"));
                System.out.println(product.getCartimages());
            }
        }catch (Exception e)
        {
            e.printStackTrace();
        }finally
        {
            JdbcUtil.relase(resultSet,preparedStatement,connection);
        }

    }
}
